<!--
 * @FilePath     : /study_code/vue2.x/transition-velocity.html
 * @Description  : Velocity.js 动画库的使用
 * @Date         : 2025-05-02 21:09:15
 * @Author       : Fang YingGui
 * @LastEditors  : fangyinggui 18715384437@163.com
 * @LastEditTime : 2025-05-03 08:16:32
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>documentName</title>
    <link rel="stylesheet" href="" />
  </head>
  <body>
    <div id="app">
      <button @click="show = !show">Toggle</button>
      <transition
        v-on:before-enter="beforeEnter"
        v-on:enter="enter"
        v-on:leave="leave"
        v-bind:css="false"
      >
        <p v-if="show">Demo</p>
      </transition>
    </div>

    <script src="/vue/dist/vue.min.js"></script>
    <script src="./lib/velocity-1.2.3.js"></script>
    <script src="./common.js"></script>
    <script>
      // 自定义组件
      const myComponent = {
        data: function () {
          return {}
        },
        props: [],
        template: ``,
        methods: {},
      }

      var app = new Vue({
        el: '#app',
        data: function () {
          return { show: false }
        },
        methods: {
          beforeEnter: function (el) {
            el.style.opacity = 0
            el.style.transformOrigin = 'left'
          },
          enter: function (el, done) {
            Velocity(el, { opacity: 1, fontSize: '1.4em' }, { duration: 300 })
            Velocity(el, { fontSize: '1em' }, { complete: done })
          },
          leave: function (el, done) {
            Velocity(el, { translateX: '15px', rotateZ: '50deg' }, { duration: 600 })
            Velocity(el, { rotateZ: '100deg' }, { loop: 2 })
            Velocity(
              el,
              {
                rotateZ: '45deg',
                translateY: '30px',
                translateX: '30px',
                opacity: 0,
              },
              { complete: done }
            )
          },
        },
      })
    </script>
  </body>
</html>
